'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, jwt, middleware } = app;


  const _jwt = middleware.jwtErr(app.config.jwt)


  router.post('/api/user/register', controller.user.register)
  router.post('/api/user/login', controller.user.login)

  // 修改用户信息
  router.post('/api/user/alterUserInfo', controller.user.alterUserInfo)

  // 修改用户密码
  router.post('/api/user/alterPassword', _jwt, controller.user.alterPassword)

  // 增加账单
  router.post('/api/bill/addBill', _jwt, controller.bill.addBill)

  


  // -----------------------------------------------------------

  // 获取账单列表
  // 将 _jwt 函数放在 router里面调用，里面一定会具备 ctx 和 next 
  router.get('/api/bill/list', _jwt, controller.bill.list)


  // 获取到可视化所需数据
  router.get('/api/bill/getAllNumber', _jwt, controller.bill.getAllNumber)


  // 用来获取账单详情
  router.get('/api/bill/detail', _jwt, controller.bill.getDetail)

  // 删除账单
  router.get('/api/bill/deleteBill',_jwt,controller.bill.deleteBill)

  // 获取到总支出/总收入
  router.get('/api/bill/data',_jwt,controller.bill.data)


  // 用来响应前端首页中，分类类型的请求
  router.get('/api/type/list', _jwt, controller.type.list)

  // 用来向用户展示页面返回本次登入的用户信息
  router.get('/api/user/showUserMsg', _jwt, controller.user.showUserMsg)



};
